package com.microservice.order.controller;

import com.microservice.common.R;
import com.microservice.order.dto.OrderDTO;
import com.microservice.order.feign.OrderClient;
import com.microservice.order.param.OrderParam;
import com.microservice.order.service.OrderService;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * write something please~
 *
 * @author huangrz
 * @since 2021/9/14
 **/
@RestController
@RequestMapping("/order")
public class OrderController implements OrderClient {

    @Autowired
    private OrderService orderService;

    /**
     * 保存订单
     *
     * @param param 下单参数
     * @return true - 成功   false - 失败
     */
    @PostMapping(value = "/save", produces = {MediaType.APPLICATION_JSON_VALUE})
    @Override
    public R<OrderDTO> save(@RequestBody OrderParam param) {
        return orderService.order(param);
    }

}
